import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutterhello/api/api.dart';
import 'package:flutterhello/controller/Controller.dart';
import 'package:flutterhello/util/host_util.dart';
import 'package:get/get.dart';

import 'widget/care_item.dart';
import '../../components/more.dart';
import 'widget/user.dart';

class FourPage extends StatefulWidget {
  @override
  _FourPageState createState() => _FourPageState();
}

class _FourPageState extends State<FourPage> {
  final _controller = Get.put(Controller());

  @override
  void initState() {
    // TODO: implement initState
    _controller.getGroups();
    _controller.getRecruitNews();
    _controller.getActiviteNews();
    _controller.getActivites();
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<Controller>(builder: (controller) {
      return Container(
        width: double.infinity,
        decoration: BoxDecoration(color: Color.fromARGB(200, 242, 242, 242)),
        child: Padding(
          padding: EdgeInsets.only(left: 10, right: 10, top: 25, bottom: 3),
          child: Column(
            children: [
              InkWell(
                onTap: () => {},
                child: UserHeader(
                  username: controller.userInfo['username'],
//              sign:"白的花胜似绿的叶，弄得酒不如淡的茶",
                  intro: "暂时还没有",
                  avatar: HostUtil.getHost() + controller.userInfo['favicon'],
                  news_tap: this._controller.recruit_news.length != 0 ||
                      this._controller.activite_news.length != 0,
                ),
              ),
              Container(
                  width: double.infinity,
                  padding: EdgeInsets.all(10),
                  margin: EdgeInsets.symmetric(vertical: 15, horizontal: 5),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      GestureDetector(
                        child: card(
                            nums: controller.myJoinGroup.length,
                            expra: "加入的团队"),
                        onTap: () => Get.toNamed('/my_join_team'),
                      ),
                      GestureDetector(
                        child: card(
                            nums: controller.myCreateGroup.length,
                            expra: "创建的团队"),
                        onTap: () => Get.toNamed('/my_create_team'),
                      ),
                      GestureDetector(
                        child: card(
                            nums: controller.myJoinAct.length, expra: "参与的活动"),
                        onTap: () => Get.toNamed('/my_join_act'),
                      ),
                      GestureDetector(
                        child: card(
                            nums: controller.myCreateAct.length,
                            expra: "发起的活动"),
                        onTap: () => Get.toNamed('/my_create_act'),
                      ),
                    ],
                  )),
              SizedBox(
                height: 10,
              ),
              GestureDetector(
                child: more(
                  icon: Icon(Icons.settings),
                  title: "设置",
                ),
                onTap: () => Get.toNamed('/setting'),
              ),
              more(
                icon: Icon(Icons.share),
                title: "分享",
              )
            ],
          ),
        ),
      );
    });
  }
}
